'use strict';

angular.module('hanxinBroker').directive('fieldFocused', function fieldFocused() {
  return {
    restrict: 'A',
    require: 'ngModel',
    link: function (scope, element, attrs, ngModel) {
      element.bind('focus', function () {
        scope.$apply(function () {
          ngModel.$focused = true;
        });
      });
      element.bind('blur', function () {
        scope.$apply(function () {
          ngModel.$focused = false;
        });
      });
    }
  };
});
